home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 12, No. 09 (1991-09)(MindCraft Publishing)(Side A).zip / Nibble Volume 12, No. 09 (1991-09)(MindCraft Publishing)(Side A).po / OFFLINE.S < prev    next >
Text File  |  1996-12-24  |  9KB  |  264 lines

  1.                          ; OFFLINE by George Powell
  2.                          ; Copyright (C) 1991, MindCraft Publ., Lincoln, MA 01773
  3.           ORG $2000      ; start at $2000
  4. MLI       EQU $BF00      ; Machine Language Interface
  5. FILENAME  EQU $0280      ; filename buffer
  6. COUT      EQU $FDED      ; character out
  7. DEVCNT    EQU $BF31      ; number of active devices
  8. DEVLST    EQU $BF32      ; list of active devices
  9. HOME      EQU $FC58      ; clear the screen
  10. NORM      EQU $FE93      ; set 40 column normal mode
  11. SERR      EQU $BF0F      ; prodos error storage
  12. PHEX      EQU $FDDA      ; print hex number
  13. MONITOR   EQU $FF65      ; monitor
  14. KEY       EQU $C000
  15. CH        EQU $0024      ; horizontal position of cursor
  16.           JMP MOVE1      ; jump over the filename buffer
  17.           DFC $EE,$EE    ; signifies a pathname buffer follows
  18.           DFC 65         ; max length of our buffer
  19. RUNTHIS   DFC 12         ; length of filename in buffer
  20.           ASC 'BASIC.SYSTEM                  '
  21.           ASC '                              '
  22.           ASC '    '     ; room for 64 bytes above
  23.           
  24. MOVE1     LDY #$00
  25. MOVE      LDA ZAP,Y      ; move program to $1000
  26.           STA $1000,Y
  27.           LDA ZAP+256,Y
  28.           STA $1100,Y
  29.           LDA ZAP+512,Y
  30.           STA $1200,Y
  31.           INY
  32.           BNE MOVE
  33.           JMP SCAN1      ; go to the relocated code
  34.           
  35.           
  36. ZAP       ORG $1000      ; new originate address
  37. SCAN1     LDA #OOPS      ; fix reset vector
  38.           STA $3F2       ; to point to the prodos selector call
  39.           LDA #OOPS/
  40.           STA $3F3
  41.           EOR #$A5
  42.           STA $3F4
  43.           JSR NORM       ; set normal 40 column display
  44.           JSR HOME       ; clear the screen
  45.           
  46.           LDY #$17
  47.           LDA #$00
  48. BMAP      STA $BF58,Y    ; clear out bitmap
  49.           DEY
  50.           BPL BMAP
  51.           
  52.           LDA #$CF
  53.           STA $BF58      ; protect zp,stack, and text
  54.           
  55.           LDA #$01
  56.           STA $BF6F      ; protect MLI global page
  57.           
  58.           
  59.           JSR PTXT       ; print the title
  60.           ASC "                OFFLINE"
  61.           DFC $8D,$8D
  62.           ASC "                  By"
  63.           DFC $8D,$8D
  64.           ASC "             George Powell"
  65.           DFC $8D,$8D
  66.           ASC "           Copyright (C) 1991"
  67.           DFC $8D,$8D
  68.           ASC "          MindCraft Publ. Corp."
  69.           DFC $8D,$8D
  70.           ASC "            Lincoln, MA 01773"
  71.           DFC $8D
  72.           ASC " "
  73.           DFC $8D,$8D
  74.           
  75.           ASC "             Active Devices"
  76.           DFC $8D
  77.           ASC "             =============="
  78.           DFC $8D,0
  79.           
  80.           LDY #$FF       ; counter for number
  81.           STY NUMGOOD    ; of good devices
  82.           
  83.           LDY #14        ; counter for devices to try
  84.           STY CNTR
  85.           
  86. SCAN      DEC CNTR
  87.           BMI WEDONE     ; our counter is less than 0
  88.           LDY CNTR       ; position in table
  89.           
  90.           LDA ALLTBL,Y   ; get device number
  91.           STA O_DEV      ; set up for MLI ONLINE call
  92.           JSR MLI        ; make MLI ONLINE call
  93.           DFC $C5
  94.           ADR O_PARM     ; online parm list
  95.           BCS SCAN       ; its not active so keep going
  96.           
  97.           LDY CNTR       ; found a active drive
  98.           INC NUMGOOD    ; increment number of active ones
  99.           LDX NUMGOOD    ; get index to active table
  100.           LDA O_DEV      ; get device number
  101.           STA TABLE,X    ; store it in the active list
  102.           ROR            ; divide device number by 16
  103.           ROR
  104.           ROR
  105.           ROR
  106.           
  107.           PHA            ; keep it safe
  108.           AND #$07       ; mask off slot bits
  109.           PHA            ; keep it safe
  110.           
  111.           LDA #13
  112.           STA CH         ; print at center of screen
  113.           
  114.           JSR PTXT       ; print slot message
  115.           ASC "Slot "
  116.           BRK
  117.           PLA            ; get back slot value off of stack
  118.           CLC            ; make it into ASCII
  119.           ADC #48
  120.           JSR COUT       ; print slot value
  121.           JSR PTXT       ; print drive message
  122.           ASC " Drive "
  123.           BRK
  124.           PLA            ; get back value from stack
  125.           ROR            ; put drive bit into position 1
  126.           ROR
  127.           ROR
  128.           AND #$01       ; mask off drive bit
  129.           CLC            ; make it into ASCII
  130.           ADC #49
  131.           JSR COUT       ; print drive number
  132.           LDA #$8D       ; print a carriage return
  133.           JSR COUT
  134.           
  135.           JMP SCAN       ; continue with scanning
  136.           
  137. WEDONE    INC $3F4       ; kill reset vector
  138.           LDY NUMGOOD    ; how many active devices
  139.           
  140.           STY DEVCNT     ; tell PRODOS
  141.           
  142. WDLP      LDA TABLE,Y    ; get active devices
  143.           STA DEVLST,Y   ; tell PRODOS about the devices
  144.           DEY
  145.           BPL WDLP
  146.           DEC $3F4       ; safe to hit reset again
  147.           
  148.           JSR MLI        ; get file info
  149.           DFC $C4
  150.           ADR IPARM      ; parm table for get info
  151.           BCS OOPS       ; ERROR
  152.           
  153.           LDA FTYPE      ; get filetype
  154.           CMP #$FF       ; is it a SYS file?
  155.           BNE OOPS       ; no, don't execute it
  156.           
  157.           JSR MLI        ; open launch pathname
  158.           DFC $C8
  159.           ADR O_TABLE
  160.           BCS OOPS       ; ERROR
  161.           LDA O_REF      ; get referance number
  162.           STA R_REF      ; let read call know
  163.           JSR MLI        ; read in the file
  164.           DFC $CA
  165.           ADR R_TABLE
  166.           BCS OOPS       ; ERROR
  167.           JSR MLI        ; close the file
  168.           DFC $CC
  169.           ADR C_TABLE
  170.           BCS OOPS       ; ERROR
  171.           
  172.           LDA KEY        ; check keyboard
  173.           CMP #155       ; is it escape (27+128)
  174.           BEQ OOPS       ; yes, use PRODOS selector
  175.           
  176.           JMP $2000      ; execute the program just loaded
  177.           
  178. OOPS      JSR MLI        ; a error in launching the program
  179.           
  180.           DFC $CC        ; so use the PRODOS selector
  181.           ADR C_TABLE
  182.           
  183.           JSR MLI
  184.           DFC $65
  185.           ADR Q_TABLE
  186.                          ; if could not execute prodos selector
  187.                          ; tell the user and why
  188.           
  189.           JSR PTXT
  190.           DFC $8D,$8D,$87,$87
  191.           ASC "PRODOS ERROR..CODE= "
  192.           BRK
  193.           LDA SERR       ; MLI error code storage
  194.           JSR PHEX       ; print error code
  195.           JMP MONITOR    ; go to the monitor
  196.           
  197. PTXT      PLA            ; imbedded text printing
  198.           STA LDD+1
  199.           PLA
  200.           STA LDD+2
  201. PTXT1B    INC LDD+1
  202.           BNE LDD
  203.           INC LDD+2
  204. LDD       LDA $FFFF      ; self modyfying code
  205.           BEQ PTXTDUN    ; 0 is end of text marker
  206.           JSR COUT       ; print it
  207.           JMP PTXT1B     ; is there more to print?
  208. PTXTDUN   LDA LDD+2      ; get address and
  209.           PHA            ; fix the stack
  210.           LDA LDD+1
  211.           PHA
  212.           RTS            ; continue with program after the 0
  213.           
  214.                          ; ALLTBL is the list of all
  215.                          ; possible device values
  216.                          ; DRIVE 1 DRIVE 2
  217.           
  218. ALLTBL    DFC $10,$90    ; SLOT 1
  219.           DFC $20,$A0    ; SLOT 2
  220.           DFC $30,$BF    ; SLOT 3
  221.           DFC $40,$C0    ; SLOT 4
  222.           DFC $50,$D0    ; SLOT 5
  223.           DFC $60,$E0    ; SLOT 6
  224.           DFC $70,$F0    ; SLOT 7
  225.           
  226.                          ; NOTE: the $bf in 3,2 is so that programs
  227.                          ; that use /RAM will see it as a RAMDISK.
  228.                          ;
  229. NUMGOOD   DFC 0          ;number of good devices
  230. TABLE     DFC 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  231. CNTR      DFC 0          ; general purpose counter
  232.           
  233. O_TABLE   DFC 3          ; open parm table
  234.           ADR RUNTHIS    ; open pathname
  235.           ADR $1C00      ; input buffer at $1C00
  236. O_REF     DFC 0          ; open reference number
  237.           
  238.           
  239. R_TABLE   DFC 4          ; read parm table
  240. R_REF     DFC 0          ; read reference number
  241.           ADR $2000      ; where to read it to
  242.           ADR $FFFF      ; how much to read..
  243.           DFC 0,0        ; how much actually read
  244.           
  245.           
  246. C_TABLE   DFC 1          ; close parm table
  247.           DFC 0          ; close reference number
  248.           
  249.           
  250. Q_TABLE   DFC 4,0,0,0,0,0,0 ; prodos selector table
  251.           
  252.           
  253. O_PARM    DFC 2          ; online parm table
  254. O_DEV     DFC 0          ; device to check
  255.           ADR FILENAME   ; where to put filename
  256.           
  257.           
  258. IPARM     DFC 10         ; get file info parm table
  259.           ADR RUNTHIS    ; path of file
  260.           DFC 0
  261. FTYPE     DFC 0          ; file type
  262.           DFC 0,0,0,0,0,0,0,0,0,0,0,0,0
  263. E
  264.